package com.wang.sort;
//在有序数组中，找 >=某个数的最左边位置
public class Demo4_BSNearLeft {
    public static int nearestIndex(int[] sortedArr,int value){

        int L = 0;
        int R = sortedArr.length - 1;
        int index = -1;
        while (L <= R){
            int mid = L + ((R - L) >> 1);
            if(sortedArr[mid] >= value){
                index = mid;
                R = mid - 1;
            }
            else{
                L = mid + 1;
            }
        }
        return index;
    }
}
